# file = open('D://test.txt','r',encoding='utf-8')
# fileContent = file.read()
# print(fileContent)
# file.close()

# w 写入模式会清空文件再写入，a 追加写入
# file = open('D://test.txt','a',encoding='utf-8')
# file.write('诸葛亮\n')
# file.write('赵云\n')
# file.close()

file = open('D://scores.txt','r',encoding='utf-8')
file_lines = file.readlines()
file.close()
print(file_lines)
final_scores = []

for i in file_lines:
      data = i.split()
      sum = 0
      print(data)
      for score in data[1:]:
            sum = sum + int(score)
      result = data[0]+":"+str(sum)+"\n"
      final_scores.append(result)

winner = open('D://winner.txt','w',encoding='utf-8')
winner.writelines(final_scores)
print('写出成功')
winner.close

